package com.zhima.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

@Data
@Slf4j
@Configuration
public class OjGatewayProperties {
    /**
     * 白名单
     */
    public static List<String> whitelist = null;

    static {
        //加载白名单
        try (
                InputStream resourceAsStream = GlobalAuthFilter.class.getResourceAsStream("/security-whitelist.properties");
        ) {
            Properties properties = new Properties();
            properties.load(resourceAsStream);
            whitelist= new ArrayList<>(properties.stringPropertyNames());
        } catch (Exception e) {
            log.error("加载/security-whitelist.properties出错:{}",e.getMessage());
            e.printStackTrace();
        }
    }
}
